import http from '../request'
import type {ForgotPasswordDTO, SendCaptchaDTO, UserLoginDTO, UserRegisterDTO} from '@/types/dto/auth'
import type {LoginVO} from '@/types/vo/auth'

export const authApi = {
    /** 发送邮箱验证码 */
    sendCaptcha(payload: SendCaptchaDTO) {
        return http.post<void>('/auth/send-captcha', payload)
    },

    /** 用户注册 */
    register(payload: UserRegisterDTO) {
        return http.post<LoginVO>('/auth/register', payload)
    },

    /** 用户登录 */
    login(payload: UserLoginDTO) {
        return http.post<LoginVO>('/auth/login', payload)
    },

    /** 退出登录 */
    logout() {
        return http.delete<void>('/auth/logout')
    },

    /** 忘记密码 */
    forgotPassword(payload: ForgotPasswordDTO) {
        return http.post<void>('/auth/forgot-password', payload)
    },
}

